package com.example.filter;

import jakarta.servlet.*;
import jakarta.servlet.annotation.WebFilter;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;

/**
 * DemoFilter 类的描述信息
 *
 * @author 12427
 * @since 2025/6/8 10:39
 */

@Slf4j
//@WebFilter(urlPatterns = "/*")//拦截所有
//Filter 导入的是 servle 包
public class DemoFilter implements Filter {

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        log.info("init  过滤器创建");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        log.info("doFilter  拦截到请求");
//        放行
        filterChain.doFilter(servletRequest,servletResponse);
    }

    @Override
    public void destroy() {
       log.info("destroy  过滤器销毁");
    }
}
